import React, { Component } from 'react';
import css from './index.less';
import FilterSearch from '@/components/FilterSearch';
import TableList from '@/components/TableList';
import { Button, Divider } from 'antd';
import { connect } from 'dva';
import { Link } from 'react-router-dom';
class operateLog extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  table = null;
  filters = [
    {
      key: 'time',
      type: 'rangepicker',
      label: '时间',
      placeholder: '请选择时间',
    },
    {
      key: 'operatorUuid',
      type: 'input',
      label: '操作人员',

      placeholder: '请输入操作人员',
    },
    {
      key: 'ip',
      type: 'input',
      label: '操作Ip',

      placeholder: '请输入操作Ip',
    },
    {
      key: 'key',
      type: 'input',
      label: '操作内容',

      placeholder: '请输入操作内容',
    },
  ];
  columns = [
    { title: '操作时间', dataIndex: 'dateTime' },
    { title: '操作人员', dataIndex: 'operatorName' },
    { title: 'Ip地址', dataIndex: 'ip' },
    { title: '操作内容', dataIndex: 'content' },
  ];
  handlerFetch(formData) {
    if (formData.time && formData.time.length) {
      formData.startTime = new Date(formData.time[0]).getTime();
      formData.endTime = new Date(formData.time[1]).getTime();
      delete formData.time;
    }
    this.table.fetch(formData);
  }
  render() {
    return (
      <div>
        <FilterSearch
          filters={this.filters}
          onSearch={val => this.handlerFetch(val)}
        ></FilterSearch>
        <TableList
          post
          rowKey="id"
          onRef={c => {
            this.table = c;
          }}
          columns={this.columns}
          source="/api/log/v1/query"
        />
      </div>
    );
  }
}

export default connect(state => state.base)(operateLog);
